//
//  LevelGageController.m
//  XTCloud
//
//  Created by QA on 2018/7/24.
//  Copyright © 2018年 ShangHai HaoLei Software Technology Co., Ltd. All rights reserved.
//

#import "LevelGageController.h"
#import "YFViewPager.h"
#import "LevelGageItemController.h"
#import "NSDictionary+DataFormat.h"

@interface LevelGageController ()

@property (nonatomic, strong) YFViewPager *viewPager;
@property (nonatomic, strong) NSMutableArray *viewController;

@end

@implementation LevelGageController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
        [self setTitle: @"料位计实时情况"];
    }
    return self;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    
    // Do any additional setup after loading the view from its nib.
    NSArray *array = self.value;
    NSArray *scLineData = [array objectAtIndex:0];
    
    self.viewController = [NSMutableArray array];
    NSMutableArray *titleArray = [NSMutableArray array];
    
    for(int i=0; i<scLineData.count; i++){
        NSDictionary *dictionary = [scLineData objectAtIndex:i];
        [titleArray addObject:[dictionary objectFormatStringForKey:@"生产线"]];
        
        LevelGageItemController *controller = [[LevelGageItemController alloc] initWithValue:dictionary];
        [self.viewController addObject:controller];
    }
    
    NSMutableArray *views = [NSMutableArray array];
    for (LevelGageItemController *controller in self.viewController){
        [views addObject:controller.view];
    }
    
    _viewPager = [[YFViewPager alloc] initWithFrame:CGRectMake(0, 0, SuperWidth, SuperHeight - 64)
                                             titles:titleArray icons:nil selectedIcons:nil views:views];
    _viewPager.tabSelectedArrowBgColor = ThemeColorBlue;
    _viewPager.tabSelectedTitleColor = ThemeColorBlue;
    _viewPager.tabTitleColor = [UIColor colorWithWhite:0 alpha:0.75];
    [self.view addSubview:_viewPager];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
